home *** CD-ROM | disk | FTP | other *** search
- // Mandlbrt.cmm - Demonstrate Graphics.lib by drawing the
- // ver.1 familiar mandlebrot fractal. This is
- // and example of GRAPHICS.LIB
-
- #include <graphics.lib>
-
- if( !defined(_DOS_) )
- {
- printf("This program will only run under the DOS %sversion of CEnvi.\n",
- defined(_DOS32_)?"(not DOS 32 bit) ":"");
- exit(EXIT_FAILURE);
- }
-
- #define ITERATIONS 32
-
- StartVGA();
-
- // pick cool red, green, and blue colors for the palette
- for ( loop = 0; loop < 64; loop++ ) {
- setpalette(64-loop, loop, loop * 2, loop * 3);
- }
-
- for ( i = 0; i < 100; i ++) {
- i2 = (i-100) * 3.0 / 200;
- for (r = 0; r < 320; r++) {
- iter = ITERATIONS;
- putpixel(r,i,1);
- putpixel(r,199-i,1);
- r2 = (r-200)*3.3 /320;
- x = 0.; y = 0.;
- do {
- iter --;
- xn = x*x - y*y;
- yn = 2*x*y;
- x = xn+r2;
- y = yn+i2;
- } while (iter > 0 ) && x*x+y*y < 4;
- putpixel(r,i,iter * 2);
- putpixel(r,199-i,iter * 2);
-
- if kbhit() {
- CloseVGA();
- exit(1);
- }
- }
- }
- getch();
-
-
- CloseVGA();
-